<?php

namespace app\common\model\mysql;

use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Model;

class ScreenUser extends BaseModel
{
    protected $schema=[
        'id'=>'int',
        'username'=>'varchar',
        'password'=>'char',
        'real_name'=>'varchar',
        'last_login_ip'=>'varchar',
        'last_login_time'=>'int',
        'status'=>'tinyint',
        'create_time'=>'int',
        'update_time'=>'int'
    ];

    /**
     * 通过username获取管理员信息
     * @param $username
     * @return array|false|Model|null
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function getScreenUserByUserName($username)
    {
        if (empty($username)) {
            return false;
        }

        $where = [
            "username" => trim($username),
        ];
        return $this->where($where)->find();
    }
}
